﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lblError.Text = "";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Security.SecurityCheck instSecuCheck = new Security.SecurityCheck();
        DataSet dsPaxInfo;
        int ret_code;
        string ret_msg;
        DateTime flt_date = System.Convert.ToDateTime(txtFltDate.Text);
        string sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(flt_date.ToString("yyyyMMdd") + "|" + txtPaxID.Text + "|" + "CAN1|TEST", "MD5");//"TEST" is CAN1's password
        try
        {
            dsPaxInfo = instSecuCheck.CheckID(flt_date, txtPaxID.Text, "CAN1", sign, out ret_code, out ret_msg);
            if (ret_code == 0)
            {
                GridView1.DataSource = dsPaxInfo;
                GridView1.DataBind();
                if(dsPaxInfo.Tables[0].Rows.Count==0)
                    lblError.Text = "Pax not found!";
                else if (dsPaxInfo.Tables[0].Rows.Count == 1)
                    lblError.Text = "";
                else //>1
                    lblError.Text = "duplicated id_no";
            }
            else
                lblError.Text = "Err:" + ret_code.ToString() + ". " + ret_msg;
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }

    }
}
